package cs6238.common.message.command;

import java.nio.ByteBuffer;
import java.util.UUID;

import cs6238.common.message.MessageId;


public class GetFileCommand extends Command {
	
	private UUID _fileId;
	
	@Override
	public byte[] serialize() {
		ByteBuffer bb = ByteBuffer.allocate(4 + 16);
		bb.putInt(MessageId.GET_FILE_COMMAND.ordinal());
		bb.putLong(_fileId.getMostSignificantBits());
		bb.putLong(_fileId.getLeastSignificantBits());
		return bb.array();
	}
	
	@Override
	public void deserialize(byte[] buffer) {
		ByteBuffer bb = ByteBuffer.wrap(buffer);
		
		bb.getInt(); //discard int
		_fileId = new UUID(bb.getLong(), bb.getLong());
	}
	
	public void setFileId(UUID fileId){
		_fileId = fileId;
	}

	public UUID getFileId() {
		return _fileId;
	}

}
